package top.soulblack.purchasesale.service;

import org.springframework.stereotype.Service;
import top.soulblack.purchasesale.mapper.GoodsSeasonMapper;
import top.soulblack.purchasesale.model.GoodsSeason;

import javax.annotation.Resource;
import java.util.List;

/**
 * create by 小川
 */
@Service
public class GoodsSeasonService {

    @Resource
    private GoodsSeasonMapper goodsSeasonMapper;

    public List<GoodsSeason> selectAll(){
        return goodsSeasonMapper.selectAll();
    }

    public void addSeason(GoodsSeason goodsSeason){
        goodsSeasonMapper.addSeason(goodsSeason);
        return;
    }

    public boolean existSeason(String name){
        int num  = goodsSeasonMapper.existSeason(name);
        if (num == 1) {
            return true;
        }
        return false;
    }

    public boolean deleteSeason(int seasonId) {
        int num = goodsSeasonMapper.deleteById(seasonId);
        if (num == 1) {
            return true;
        }
        return false;
    }

    public boolean updateSeason(GoodsSeason goodsSeason) {
        int num = goodsSeasonMapper.updateByPrimaryKey(goodsSeason);
        if (num == 1) {
            return true;
        }
        return false;
    }
}
